<template>
    <view class="chicken_box">
        <img
			v-if="authority === 'salesman'"
            src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/09/20/3f1a1d95feb74500919d5426dae28e46.png"
            alt=""
            @click="toGoodsDetail()"
        />
        <img
            src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/09/20/3cfeb909553e4369902227c1340f074a.png"
            alt=""
            @click="toChicken()"
        />
		<view class="chicken" @click="toChickenReceive()">
			<u-text text="福鸡转赠" size="44rpx" color="#fff" />
			<u-text text="您的福鸡赠送给您的好友~" size="28rpx" color="rgba(255,255,255,0.8)" margin="8rpx 0 32rpx" />
			<view class="btn">去转赠</view>
		</view>
		
		<view class="chickenS" @click="toChickenWarehouse()">
			<u-text text="福鸡仓库" size="44rpx" color="#fff" />
			<u-text text="未激活的福鸡都在这~" size="28rpx" color="rgba(255,255,255,0.8)" margin="8rpx 0 32rpx" />
			<view class="btn btns">去转赠</view>
		</view>
    </view>
</template>

<script>
import caches from "@/config/caches.js";
import { chickUrl } from "@/config/tendIdConfig.js";
import { encryption } from "@/utils/encryption.js";
export default {
    data() {
       return {
           authority: this.$store.getters?.authority ?? "customer",
       };
    },
    methods: {
        toGoodsDetail() {
            uni.$u.route({
                // url: `pages_shop1/goods/index?id=1674643513790054402`,
                url: `pages_shop1/goods/index?id=1664195155138473986`,
            });
        },
			
		toChickenReceive(){
			const phone = uni.getStorageSync(caches.PHONE);
			if (!phone) return uni.navigateTo({
				url: "/pages/user/phone/indexApp",
			});
			uni.$u.route({
			    url: `pages_chicken/index/index`,
			});
		},
		toChickenWarehouse(){
			const phone = uni.getStorageSync(caches.PHONE);
			if (!phone) return uni.navigateTo({
				url: "/pages/user/phone/indexApp",
			});
			uni.$u.route({
			    url: `pages_chicken/index/indexWarehouse`,
			});
		},
        toChicken() {
			const phone = uni.getStorageSync(caches.PHONE);
			if (!phone) return uni.navigateTo({
				url: "/pages/user/phone/indexApp",
			});
            wx.request({
                url: chickUrl + "/api/v1/auth/phone-login",
                method: "POST",
                data: {
                    ...encryption({
                        user_phone: phone,
                    }),
                },
                success: (res) => {
                    this.token = res.data.data.token;
                    // 使用 uni.navigateTo 替换 wx.navigateTo，支持跨平台
                    uni.navigateTo({
                        url: `/pages_shop1/pay/chickenDetail/jump?url=${encodeURIComponent(
                            chickUrl + "/go"
                        )}&api_token=${this.token}`,
                    });
                    console.log(this.token, "11");
                },
                fail: (err) => {
                    console.log(err, "22");
                },
            });
        },
    },
};
</script>

<style lang="scss">
.chicken_box {
    background-color: #fff;
    height: 100vh;
    // text-align: center;
    padding: 60rpx 30rpx;
    img {
        width: 100%;
        height: 288rpx;
    }
}
.chicken {
	width: 100%;
	height: 288rpx;
	background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2024/01/19/91f378153abc483ea012dee56ceaccc3.png");
	background-repeat: no-repeat;
	background-size: 100% 100%;
	padding: 60rpx;
}
.chickenS{
	width: 654rpx;
	height: 248rpx;
	background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2025/09/30/de77469821fa4561be598f517d27f7d4.png");
	background-repeat: no-repeat;
	background-size: 100% 100%;
	padding: 46rpx 48rpx;
	margin: 18rpx auto 0;
}
.btn , .btns{
	width: 120rpx;
	height: 56rpx;
	background: #FFFFFF;
	border-radius: 56rpx;
	font-size: 24rpx;
	color: #8277FD;
	line-height: 56rpx;
	text-align: center;
}
.btns{
	color: #FF7944;
}
</style>
